package desktop.playerguide;

import pulpcore.Stage;
import pulpcore.image.Colors;
import pulpcore.image.CoreFont;
import pulpcore.image.filter.Glow;
import pulpcore.scene.Scene2D;
import pulpcore.sprite.ImageSprite;
import pulpcore.sprite.Label;

public class PlayerGuideScene extends Scene2D {

	double angle = 0;
	Label[] labels = new Label[4];
	ImageSprite[] choices = new ImageSprite[4];
	String[] choiceNames = { "desktopMode", "webModel", "optionModel",
			"aboutModel" };

	private void positionChoices() {
		for (int i = 0; i < choices.length; i++) {
			double choicesAngle = angle + i * (2 * Math.PI) / choices.length;
			double x = Math.cos(choicesAngle) * 200;
			double y = Math.sin(choicesAngle) * 100;
			double scale = 0.25 + (y + 100) / 266;
			double w = scale * choices[i].getImage().getWidth();
			double h = scale * choices[i].getImage().getHeight();

			choices[i].setLocation(x + 320, y + 240);
			choices[i].setSize(w, h);
			labels[i].setLocation(x + 320, y + 240 + h / 2);
		}
	}

	@Override
	public void load() {
		add(new ImageSprite("mainwindow.png", 0, 0,Stage.getWidth(),Stage.getHeight()));

		CoreFont font = CoreFont.getSystemFont().tint(Colors.WHITE);
		for (int i = 0; i < choices.length; i++) {
			labels[i] = new Label(font, choiceNames[i], 0, 0);
			labels[i].setAnchor(0.5, 0);
			labels[i].setFilter(new Glow(0.25));

			choices[i] = new Choice(choiceNames[i] + ".png", labels[i]);
			add(choices[i]);
			add(labels[i]);
		}
		positionChoices();
	}

	public void update(int elapsedTime) {
		super.update(elapsedTime);
		double dAngle = elapsedTime * Math.PI / 10000;
		angle = (angle + dAngle) % (2 * Math.PI);
		positionChoices();
	}
}
